﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Pyramid
{
    class CLBandDetail:Blend
    {
        public override void Init(int MRMethod, int ExtensionMethod)
        {

            int l, level;

            double[] r = new double[CoarseImage.Depth];

            init_general(MRMethod, ExtensionMethod);

         

            //build the pyramid itself
            ImagePyramid = new List<GImage>();
            ImagePyramid.Add(CoarseImage);
            level = 1;
            ImageWithDetail c = new ImageWithDetail();
            ImageWithDetail d = new ImageWithDetail();
            c.TheImage = new GImage(CoarseImage);
            c.TheDetails = new List<GImage>();
            for (l = coarse_level + 1; l <= fine_level - 1; l++)
            {
                double alpha = (1.0) * (l - coarse_level) / (fine_level - coarse_level);
                //d.TheImage = (1 - alpha) * d.TheImage + alpha * G[level-1].TheImage;
                c.TheDetails = Fine_Image_Pyramid[level - 1].TheDetails;
                if (MR.AmplifyDetails && MR.Amp_Factor == 0) MR.Amp_Factor = alpha;
                c = MR.UpSample(c);

                //c.TheImage = (1 - alpha) * c.TheImage + alpha * (G[level].TheImage-c.TheImage);
                c.TheImage = c.TheImage + alpha * (Fine_Image_Pyramid[level].TheImage - c.TheImage);
                level++;
                GImage nextimage = new GImage(c.TheImage);
                ImagePyramid.Add(nextimage);
            }
            ImagePyramid.Add(FineImage);

        }
    }
}
